package com.nondo.dean.product.controller.wap.app;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.nondo.dean.product.domain.ProductWithBLOBs;
import com.nondo.dean.product.service.ProductService;

@Controller("apiWapProduct")
@RequestMapping("/wap/app/product")
public class ProductController {

    @Autowired
    private Environment environment;
    
    @Autowired
    ProductService productService;

    /**
     * 获取活动详情
     *
     * @param request
     * @param response
     * @return
     */
    @RequestMapping("/info/{id}")
    public ModelAndView getProductByType(HttpServletRequest request, HttpServletResponse response,
        @PathVariable("id") Integer id) {
        ModelAndView mv = new ModelAndView("wap/app/product/info");
        ProductWithBLOBs productWithBLOBs = null;
        productWithBLOBs = this.productService.selectById(id);
        if (productWithBLOBs != null) {
            productWithBLOBs.setName(productWithBLOBs.getName());
            productWithBLOBs.setDetailInfo(productWithBLOBs.getDetailInfo());
        } else {
            productWithBLOBs = new ProductWithBLOBs();
        }
        mv.addObject("productWithBLOBs", productWithBLOBs);
        return mv;
    }

}